import { Chesstype } from "../types/enums";
import './Chess.css'
interface Iprops {
  type: Chesstype
  width?: number
  height?: number
  onClick?: () => void
}
export function Chess(prop: Iprops) {
  let chess = null, { type, width = 50, height = 50, onClick = () => { } } = prop;
  const style = {width: width+'px', height: height+'px'}
  if (type === Chesstype.red) {
    chess = "red"
  } else if (type === Chesstype.blue) {
    chess = "blue"
  }
  return (<div className="chess" style={style} onClick={() => {
    // 空白才处理
    if (type === Chesstype.none) onClick();
  }}>
    <div className={chess + ' chess-item'}></div>
  </div>);
}